package utils;

/**
 * @author kevin
 * @desc 数组通用函数
 */
public class ArrayUtils {
	
	/**
	 * 将数组的每个元素用分隔符连接
	 * @param array
	 * @param delimiter  分隔符
	 * @return
	 */
	public static String glue(Object[] array, String delimiter) {
		StringBuilder resultBuilder = new StringBuilder("");
		if (null == array || 0 == array.length) {
			return "";
		}
		int size = array.length;
		for (int i = 0; i < size; ++i) {
			resultBuilder.append(array[i].toString());
			if (i + 1 != size) {
				resultBuilder.append(delimiter);
			}
		} 
		return resultBuilder.toString();
	}
}
